﻿@using OSBLE.Areas.AssignmentWizard.Controllers
@using OSBLE.Areas.AssignmentWizard.Models
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Header
{
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/json2.min.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/AssignmentWizard/Content/css/layout.css")" type="text/css" rel="Stylesheet" />
    @RenderSection("Header", false)
}
<div id="WizardContent">
<h1>@ViewBag.Title</h1>
@using (Html.BeginForm("Index", null, FormMethod.Post, new { id = "WizardForm" }))
{
    <ul id="QuickNav">
        
            <li class="QuickNavItem QuickNavNotActive"><a href="#" onclick="changePage('');">Assignment Components</a></li>
            @foreach (WizardBaseController comp in ViewBag.Components)
            {
                string liClasses = "QuickNavItem";
                if (comp.ControllerName == ViewBag.ActiveComponent.ControllerName)
                {
                    liClasses += " QuickNavActive";
                }
                else
                {
                    liClasses += " QuickNavNotActive";
                }
                //AC Note: Style breaks if you place the <LI> and <A> on different lines, so I've
                //just thrown the whole thing into the IF statement.
                if (ViewBag.Assignment != null && ViewBag.Assignment.ID != 0 && ViewBag.IsNewAssignment == false)
                {
                <li class="@liClasses"><a href="#" onclick="changePage('@comp.ControllerName');">@comp.PrettyName</a></li>
                }
                else
                {
                    <li class="@liClasses">@comp.PrettyName</li>
                }

            }
        
    </ul>
<div id="WizardFormBody">
@RenderBody()
</div>
<div id="WizardBottomNav" style="clear:both;">
        <input type="submit" value="Previous" name="@WizardNavButtons.PreviousButton" />
        @if (ViewBag.IsNewAssignment == false)
        {
            <input type="submit" value="Save & Exit" name="@WizardNavButtons.SaveAndExitButton" />   
        }
        @if (ViewBag.Assignment != null && ViewBag.Assignment.ID != 0)
        {
            <input type="button" value="Reset Values" name="@WizardNavButtons.ResetFormButton" onclick="resetPage();" />
        }
        <input type="submit" value="Next" name="@WizardNavButtons.NextButton" />
        <input type="hidden" id="ComponentNameNavSelect" name="ComponentName" />
</div>
}
@using (Html.BeginForm("QuickNav", null, FormMethod.Post, new { id = "QuickNavForm" }))
{
    <input type="hidden" id="DummyComponentNameNavSelect" name="ComponentName" />
}
<!--end of "WizardContent"-->
</div>
<script type="text/javascript">
    function resetPage() {
        $("#DummyComponentNameNavSelect").val("@(ViewBag.ActiveComponent.ControllerName)");
        $("#QuickNavForm").submit();
    }
    function changePage(page) {
        $("#ComponentNameNavSelect").val(page.toString());
        $("#WizardForm").submit();
    }
</script>